#include "SceneGraph.h"

using namespace gull::core;
using namespace std;

SceneGraph::SceneGraph():
m_root("root", RENDERPASS_START)
{
    pair<const char*,ISceneNode*> p(m_root.getName(),&m_root);
    m_sceneNodes.insert(p);
}

SceneGraph::~SceneGraph()
{
    m_sceneNodes.clear();
}

SceneGraph::SceneGraph(const SceneGraph& s):
m_root(s.m_root)
{
    
}

ISceneNode*
SceneGraph::findNode(const char *name) const
{
    return m_sceneNodes.find(name)->second;
}

void
SceneGraph::addNode(ISceneNode* n)
{
    if(n){
        if(!n->getParent()){
            n->setParent(&m_root);
			m_root.addChild(n);
        }
        
        m_sceneNodes.insert(stringSceneNodePair(n->getName(),n));
    }
    
}